﻿using System;
using System.Collections.Generic;
using System.Text;
using AspectCore.Configuration;
using FDSimpleModelGenerator.Common;

namespace FDSimpleModelGenerator.Aop
{
    /// <summary>
    /// Aop日志解析
    /// </summary>
    public class AopLogTypeResolver
    {
        private readonly IAspectConfiguration _configuration;
        private readonly AopOptions _options;

        public AopLogTypeResolver(IAspectConfiguration configuration, AopOptions options)
        {
            _configuration = configuration;
            _options = options;
        }

        public void Resolve()
        {
            if (_options.AopLogType == AopLogType.MethodType)
            {
                if (!_options.NonLogPredicates.IsNullOrEmpty())
                {
                    var nonLogPres = _options.NonLogPredicates.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var nonLogPre in nonLogPres)
                    {
                        // 先看看支
                        _configuration.NonAspectPredicates.AddMethod(nonLogPre);
                    }
                }
            }
        }
    }
}
